import requests


def send_single_sms(apiKey, code, mobile):
    url = "https://sms.yunpian.com/v2/sms/single_send.json"
    text = "[爱学习]您的验证码是{},如非本人操作，请忽略本短信.".format(code)
    resp = requests.post(url, data={
        "apikey": apiKey,
        "mobile": mobile,
        "text": text
    })
    return resp


if __name__ == '__main__':
    res = send_single_sms("1111111", 123, "18146549752")
    import json

    json_res = json.loads(res.text)
    code = json_res['code']
    print(str(json_res))
